<template>
	<view>
		<view class="" style="text-align: center;margin-top: 50rpx;" v-if="list.length==0">
			<image src="../../static/no.png" mode="scaleToFill"
				style="margin-top: 100rpx;width: 300rpx;height: 300rpx;"></image>
			<view class="" style="color: #999;font-size: 28rpx;margin-top: 20rpx;">
				暂无记录
			</view>
		</view>
		<view class="box">
			<view class="userbox" @click="news(item,index)" v-for="(item, index) in list" :key="index">
				<image :src="item.wx_avatar" mode=""></image>
				<view class="user">
					<view class="name">
						<view class="left">
							{{item.user_name}}
						</view>
						<view class="right">
							{{item.create_time}}
						</view>
					</view>
					<view class="bott">
						<view class="text">
								{{item.content}}
						</view>
						<text v-if="item.unread > 0">	{{item.unread}}</text>
					</view>
				</view>
			</view>
			
		</view>


	</view>
</template>

<script>
	import {
		chatList
	} from '../../api/api.js'
	export default {
		data() {
			return {
				list: []
			};
		},
		onLoad() {
			
		},
		mounted() {
			chatList(1).then(res=>{
				this.list = res.data
			})
		},
		methods: {
			news(item,index) {
				this.list[index].unread = 0
				uni.navigateTo({
					url: '/pages/userSide/privateChat?id=' + item.another_id + "&ava=" + item.wx_avatar+ "&status=1"
				})
			}
		}
	}
</script>
<style>
	page {
		background-color: #fff;
	}
</style>
<style lang="scss">
	.box {
		width: 92vw;
		margin: 0 auto;
	}

	.userbox {
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: #fff;
		margin: 20rpx 0;
		padding: 20rpx;

		image {
			width: 80rpx;
			height: 80rpx;
			border-radius: 15rpx;
		}

		.user {
			width: 72vw;

			.name {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.left {
					font-weight: bold;
					font-size: 36rpx;
					color: #333;
				}

				.right {
					font-size: 26rpx;
					color: #999;
				}
			}

			.bott {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.text {
					margin-top: 10rpx;
					color: #666;
					font-size: 22rpx;
					width: 60vw;
					text-overflow: ellipsis;
					overflow: hidden;
					white-space: nowrap;
				}

				text {
					width: 40rpx;
					line-height: 40rpx;
					border-radius: 50rpx;
					background-color: red;
					color: #fff;
					font-size: 20rpx;
					text-align: center;
					display: inline-block;
				}
			}

		}
	}
</style>
